package cn.com.tianpeidong.restaurantadmin.project.admin.pos.entity;

import cn.com.tianpeidong.restaurantadmin.common.util.date.DateUtils;
import cn.com.tianpeidong.restaurantadmin.project.admin.dishes.entity.Dishes;
import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Objects;

/**
 * @author tianpeidong
 * @version 创建时间: 19-6-1 下午1:42
 */
@Data
public class SaleLineItem implements Serializable {

    private Long saleId;
    private Dishes dishes;
    private BigDecimal subTotal;
    private Integer amount;
    private String remark;
    private String date;

    public BigDecimal getSubTotal() {
        return this.dishes.getPrice().multiply(new BigDecimal(this.amount)).setScale(2, BigDecimal.ROUND_HALF_DOWN);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        SaleLineItem that = (SaleLineItem) o;
        return dishes.equals(that.dishes);
    }

    @Override
    public int hashCode() {
        return Objects.hash(dishes);
    }

}
